/* 冰河洗剑 2020.4.5
 * 一个基本OpenGL控件
 * 包含一个shader和一个camera,并具有利用键盘鼠标使相机漫游的功能
 * wasd控制相机前后左右移动，鼠标控制俯仰角和偏航角（滚转角暂时没动）
 *
*/


#ifndef BHXJGLBASEWIDGET_H
#define BHXJGLBASEWIDGET_H

#include<QOpenGLWidget>
#include<QMouseEvent>
#include<QKeyEvent>
#include "BHXJGLHelper/bhxjglshader.h"
#include "BHXJGLHelper/bhxjglcamera.h"
#include "BHXJGLHelper/bhxjglinclude.h"
#include "BHXJControls_global.h"
class BHXJCONTROLS_EXPORT BHXJGLBaseWidget : public QOpenGLWidget,protected BHXJGLFUN
{
    Q_OBJECT
public:
    explicit BHXJGLBaseWidget(QWidget *parent = nullptr);

signals:

protected:
    std::atomic_bool updated;
    bool timerID{0};
    bool move=true;
    QPoint p;
    QMap<int, bool> keys;
    virtual  void mousePressEvent(QMouseEvent *event) override;
    virtual  void mouseReleaseEvent(QMouseEvent *event) override;
    virtual  void mouseMoveEvent(QMouseEvent *event) override;

    virtual void focusOutEvent(QFocusEvent *e)override;

    virtual void keyPressEvent(QKeyEvent *e) override;
    virtual void keyReleaseEvent(QKeyEvent *e) override;

    virtual void timerEvent(QTimerEvent *) override;


    BHXJGLShader shader;
    BHXJGLCamera camera;

    glm::mat4 projection;
    glm::mat4 model = glm::mat4(1.0f);
    glm::mat4 view = glm::mat4(1.0f);

public slots:
};

#endif // BHXJGLBASEWIDGET_H
